package org.zoomdev.zoom.dao.adapters.parameter;

import org.zoomdev.zoom.dao.adapters.ParameterAdapter;

import java.sql.PreparedStatement;
import java.sql.SQLException;

// 枚举适配器（按序号存储）
public class EnumOrdinalParameterAdapter<E extends Enum<E>> implements ParameterAdapter<E> {

    public static final EnumOrdinalParameterAdapter<?> ADAPTER = new EnumOrdinalParameterAdapter<>();

    @Override
    public void setNonnullParameter(PreparedStatement ps, int index, E data) throws SQLException {
        ps.setInt(index, data.ordinal());
    }
}
